SeqRun = {}
function SeqRun:Run(...)
    if arg.n < 2 then
        assert(false)
        return
    end

    local tbl = 
    {
        n = 1, 
        list = {},
        bInserted = false,
        RunNext = function(self) 
            self.bInserted = false
            if (self.n >= #self.list) then
                return
            end
            self.n = self.n + 1
            self.list[self.n](self)
        end,
        GetNext = function(self)
            self.bInserted = false
            self.n = self.n + 1
            if (self.n <= #self.list) then
                return function() self.list[self.n](self) end
            else
                return function() end
            end
        end,
        -- CAN NOT Insert twice
        Insert = function(self, ...)
            assert(self.n <= #self.list)
            assert(not self.bInserted)
            self.bInserted = true
            for i=1,arg.n do
                table.insert(self.list, self.n + i, arg[i])
            end
        end,
    }
    for i=1, arg.n do
        tbl.list[i] = arg[i]
    end

    arg[1](tbl)
end

-- test
--function ac4(objRun)
--    print("ac4")
--    objRun:RunNext()
--end
--function ac5(objRun)
--    print("ac5")
--    objRun:RunNext()
--end
--
--
--function ac1(objRun)
--    print("ac1")
--
--    objRun:Insert(ac4, ac5)
--
--    objRun:RunNext()
--end
--function ac2(objRun)
--    print("ac2")
--    objRun:RunNext()
--end
--function ac3(objRun)
--    print("ac3")
--    objRun:RunNext()
--end
--SeqRun:Run(ac1,ac2,ac3)